package com.lottery.material.service.portal.menuLevel.impl;

import com.lottery.material.dao.base.BaseDao;
import com.lottery.material.dao.portal.menuLevel.MenuLevelConfigDao;
import com.lottery.material.entity.conf.MenuLevelConfig;
import com.lottery.material.service.base.impl.BaseServiceImpl;
import com.lottery.material.service.portal.menuLevel.MenuLevelConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author:houjie
 * @Description: 分类接口实现类
 * @Date:Create in 2019/4/10 15:17
 */
@Service
@Slf4j
public class MenuLevelConfigServiceImpl extends BaseServiceImpl<MenuLevelConfig, Integer> implements MenuLevelConfigService {

    @Autowired
    private MenuLevelConfigDao menuLevelConfigDao;

    @Override
    public BaseDao<MenuLevelConfig, Integer> getBaseDao() {
        return menuLevelConfigDao;
    }

    @Override
    public MenuLevelConfig findByMenuCode(String menuCode) {
        return menuLevelConfigDao.findByMenuCode(menuCode);
    }

    /**
     * description: 根据菜单类型查询菜单列表
     * author sunny
     * createDate 2019-04-11 上午 9:33
     * @param menuType
     * @return
     */
    @Override
    public List<MenuLevelConfig> findMenuModuleListByMenuType(Integer menuType) {
        if (menuType == 1) {  //查询一级类别且加入到模块的菜单
            return menuLevelConfigDao.findByLevelTypeAndIsJoinModuleEqualsOrderBySortAsc(1, 2);
        } else if (menuType == 2) {  //查询二级类别菜单
            return menuLevelConfigDao.findByLevelTypeOrderBySortAsc(2);
        } else {
            return null;
        }
    }
}
